package fy.form.groovy;

import fy.config.FyConfig;
import fy.util.DBUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class GroovyFunc3 {

    private static final Log logger = LogFactory.getLog(GroovyFunc3.class);

    private static Long[] zjlLevelIDArray;

    private static void init() {
        Connection conn = null;
        PreparedStatement pst = null;
        ResultSet rs = null;
        try {
            conn = DBUtil.connect(FyConfig.getOA_DB_CONFIG());
            java.util.List<Long> levelArray = new java.util.ArrayList<Long>();
            while (rs.next()) {
                levelArray.add(rs.getLong(1));
            }

            zjlLevelIDArray = levelArray.toArray(new Long[levelArray.size()]);

            levelArray.clear();
            levelArray = null;
        } catch (Exception ex) {
            logger.error("初始化GroovyFunc3发生异常", ex);
        } finally {
            DBUtil.close(rs, pst, conn);
        }
    }

    public static int isZJL(Object object) {
        try {
            long level = Long.valueOf(String.valueOf(((Object[]) object)[0]).replace("Level|", ""));
            for (int i = 0, length = zjlLevelIDArray.length; i < length; i++) {
                if (level == zjlLevelIDArray[i]) {
                    return 1;
                }
            }
        } catch (Exception ex) {
            logger.error("GroovyFunc3 isZJL发生异常", ex);
        }
        return 0;
    }

}
//{"_currentDiv":{"_currentDiv":"0"},"mainbodyDataDiv_0":{"id":"-1","createId":"0","createDate":"2015-10-03 14:47:58.868","modifyId":"-1825607432309486470","modifyDate":"2015-11-02 14:30:25.097","moduleType":"36","moduleId":"0","contentType":"20","moduleTemplateId":"-4165775831353899684","contentTemplateId":"-7392070433096708211","sort":"1","title":"事项跟踪","content":"","rightId":"8476042826308209520","status":"STATUS_RESPONSE_VIEW","viewState":"1","contentDataId":"4636092790629113753"},"formmain_3965":{"field0002":"11111111","field0003":"222222222","field0004":"2333333","field0011":"","field0008":"","field0009":"","field0010":"","field0006":"","field0007":"","field0007_0_editAtt":"true","field0012":"","field0005":""},"attachmentInputs":[]}
